import { ui } from "../../ui/layaMaxUI";
import Game from "../../core_wq/game/Game";
import GameEvent from "../../core_wq/game/GameEvent";
import EffectUtil from "../../core_wq/utils/EffectUtil";
import SignView from "../sign/SignView";



export default class RightView extends ui.moduleView.main.RightViewUI {

    private timeLine: Laya.TimeLine;

    _isInit = false;

    constructor() {
        super();
        Laya.stage.on(GameEvent.SHOW_MAIN, this, this.show);
        Laya.stage.on(GameEvent.START_GAME, this, this.hide);
        this.x += 500;
    }


    onEnable() {
        if (this.signBtn && this._isInit !== true) {
            this._isInit = true;
            this.signBtn.on(Laya.Event.CLICK, this, this.clickSign);
        }
    }

    clickSign(){
      Game.sceneManager.main.addChild(new SignView());
    }

    show() {
        Laya.Tween.to(this, { x: (this.x - 500) }, 500, Laya.Ease.sineOut);
        if (this.timeLine == null) {
            this.timeLine = EffectUtil.playLoopChangeSize(this, undefined);
        }
        this.timeLine.play(0, true);
    }

    hide() {
        if (this.timeLine != null) {
            this.timeLine.pause();
        }
        Laya.Tween.to(this, { x: (this.x + 500) }, 500, Laya.Ease.sineOut);
    }




}